package mcsm.GUI.LeftPanel;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;

import mcsm.GUI.LabelButton;
import mcsm.GUI.MyFrame;
import mcsm.GUI.RightPanel.RightPanel;
import mcsm.GUI.RightPanel.RightPanelFactory;
import mcsm.Model.Person;
import mcsm.Model.Staff;

public class CashierLeftPanel extends FunctionLeftPanel {
	CashierLeftPanel(Person cashier, int width, int height, MyFrame frame) {
		super(cashier, width, height, frame);
	}
	
	private class CashierUpPanel extends FunctionUpPanel {

		public CashierUpPanel(int width, int height) {
			super(width, height);
		}
		
	}
	
	private class CashierDownPanel extends FunctionDownPanel {
		public CashierDownPanel(int width, int height) {
			super(width, height);	
			this.setButtons(1);
		}
		
		@Override
		protected int setOtherLabelsAndSetY() {
			ImageIcon sale_nor = new ImageIcon(this.getClass().getResource("/SEED/icon/sale_nor.gif"));
			ImageIcon sale_sel = new ImageIcon(this.getClass().getResource("/SEED/icon/sale_sel.gif"));
			
			LabelButton saleB; 
			saleB = new LabelButton(x, y, sale_nor, sale_sel, thisPanel);
			saleB.addMouseListener(new SaleButtonListener());
			increaceY();
			
			this.setLayout(null);
			this.add(saleB.getLabel());	
			
			return y;
		}
	}
	
	protected UpPanel createUpPanel(int width, int height) {
		return new CashierUpPanel(width, height);
	}
	
	protected DownPanel createDownPanel(int width, int height) {
		return new CashierDownPanel(width, height);
	}
	
	private class SaleButtonListener extends MouseAdapter{
		public void mouseClicked(MouseEvent e) {
			RightPanel rp = RightPanelFactory.createSaleRightPanel(frame,(Staff)person);
			frame.setRightPanel(rp);
		}
	}
}
